package com.fausto.learnimprint.core.controller.impl

import com.fausto.learnimprint.common.enum.ResultCodeEnum
import com.fausto.learnimprint.core.model.dto.CommonResult
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.servlet.http.HttpServletResponse

@RestController
class ErrorController {

    @Autowired
    lateinit var response: HttpServletResponse

    /**
     *      404错误
     */
    @RequestMapping("/notfound")
    fun notFound(): CommonResult<Any> {
        response.status = HttpServletResponse.SC_NOT_FOUND
        return CommonResult.build(null, ResultCodeEnum.NOT_FOUND)
    }

    @RequestMapping("/frequent")
    fun frequent(): CommonResult<Any> {
        return CommonResult.build(null, ResultCodeEnum.REPEAT_ERROR)
    }
}